package com.sunspring.jbug.service;

import com.google.common.collect.Maps;
import com.sunspring.jbug.dto.count.BugCount;
import com.sunspring.jbug.mapper.ReportMapper;
import com.sunspring.jbug.param.ReportParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author: wulei
 * @Date: 2019/3/10
 */
@Service
public class ReportService {

    @Autowired
    private ReportMapper reportMapper;

    /**
     * 项目bug数量统计
     */
    public BugCount getBug(ReportParam reportParam) {
        return reportMapper.selectBugCount(reportParam);
    }

    /**
     * 项目模板/版本数量统计
     */
    public Map<String,Integer> getVersionAndModule(ReportParam reportParam) {
        Map<String,Integer> map = Maps.newHashMapWithExpectedSize(2);
        Integer moduleCount = reportMapper.selectModuleCount(reportParam.getProjectId());
        Integer versionCount = reportMapper.selectVersionCount(reportParam.getProjectId());
        map.put("moduleCount",moduleCount);
        map.put("versionCount",versionCount);
        return map;
    }
}

